﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Xomega.Framework;
using System.Globalization;

namespace AdventureWorks.Client.WPF
{
    /// <summary>
    /// Interaction logic for Errors.xaml
    /// </summary>
    public partial class Errors : Window
    {
        public static void Show(ErrorList errorList)
        {
            Errors wErr = new Errors();
            wErr.lstErrors.ItemsSource = errorList.Errors;
            wErr.Show();
        }

        public Errors()
        {
            InitializeComponent();
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }

    class SeverityToBrushConverter : IValueConverter
    {
        public Brush Warning { get; set; }
        public Brush Error { get; set; }
        public Brush Critical { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (ErrorSeverity.Warning.Equals(value)) return Warning;
            else if (ErrorSeverity.Error.Equals(value)) return Error;
            if (ErrorSeverity.Critical.Equals(value)) return Critical;
            else return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }
    }
}
